package cn.com.controller;


import cn.com.constant.Code;
import cn.com.util.DataResult;
import cn.com.util.JsonUtil;
import cn.com.util.qiniuUtil;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/qiniu/")
public class qiniuController {

    @RequestMapping(value = "uploadToken",method = RequestMethod.GET)
    public String getUploadToken(){
        DataResult dataResult=new DataResult();
        dataResult.setCode(Code.SUCCESS);
        dataResult.setMessage("返回成功");
        dataResult.setData(qiniuUtil.getUpToken());
        return JsonUtil.toJsonString(dataResult);
    }


    @RequestMapping(value = "coverUploadToken/{fileKey}",method = RequestMethod.GET)
    public String getCoverUploadToken(@PathVariable("fileKey")String fileKey){
        DataResult dataResult=new DataResult();
        dataResult.setCode(Code.SUCCESS);
        dataResult.setMessage("返回成功");
        dataResult.setData(qiniuUtil.getDefaultCoverUpToken(fileKey));
        return JsonUtil.toJsonString(dataResult);
    }

}
